﻿using Prism.Mvvm;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Net.WebRequestMethods;

namespace Wemail.Common.Http
{
    public static class RestHelper 
    {
        private static string _baseApi = "http://api.pingcc.cn/";
        private static RestClient _restClient;

        static RestHelper() {
            _restClient = new RestClient();
        }
        public static async Task<string> MakeHttpRequestAsync(string query)
        {  
            var url= _baseApi+ "fiction/search/title/"+ query;
            var request = new RestRequest(url, Method.GET);

            IRestResponse response = await _restClient.ExecuteAsync(request);

            return response.Content;
        }
        public static async Task<string>  GetChapter(string query)
        {
            var url = _baseApi + "fictionChapter/search/" + query;
            var request =new RestRequest(url, Method.GET);
            IRestResponse response = await _restClient.ExecuteAsync(request);
            return response.Content;
        }
           public static async Task<string>  GetContent(string query)
        {
            var url = _baseApi + "fictionContent/search/" + query;
            var request =new RestRequest(url, Method.GET);
            IRestResponse response = await _restClient.ExecuteAsync(request);
            return response.Content;
        }
    }
}
